const db = uniCloud.database()
const resume = db.collection('resume')
exports.main = async (event, context) => {
	const {
		_id
	} = event
	let {
		data
	} = await resume.where({
		_id
	}).get()

	await Promise.all(data.map(async item => {
		if (!item.user_head) {
			item.user_head_img = ''
			return
		}
		let result = await uniCloud.getTempFileURL({
			fileList: [item.user_head]
		});
		if (result.fileList && result.fileList.length) {
			let fileInfo = result.fileList[0]
			if (fileInfo.code === "SUCCESS") {
				item.user_head_img = fileInfo.download_url
			}
		}
	}))

	return {
		code: 1,
		data: data[0]
	}
};
